package cjh;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import model.SubjectVO;


// 과목정보  등록

public class Admin_Apend_Sub extends JDialog {

	private final JPanel contentPanel = new JPanel();
	static SubjectVO v = new SubjectVO();
	static JTextField get[] = new JTextField[6];
	static Admin_Service as = new Admin_Service();
	
	public Admin_Apend_Sub( ) {
		setTitle("과목 정보 추가등록");
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(  new GridLayout(0, 1, 0, 10) );
				
		JPanel check[] = new JPanel[6];
		
		JLabel stu[] =  new JLabel[6];
		
		
		
		//contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
		for ( int i = 0; i <= 5; i++){
			
			
			check[i] = new JPanel();
			stu[i] = new JLabel();
			get[i] = new JTextField();
			
			
			check[i].setLayout( new BoxLayout(check[i], BoxLayout.X_AXIS));
			check[i].add( stu[i] );
			check[i].add( get[i] );
			
			contentPanel.add( check[i]);	
						
		}
		stu[0].setText( "과목 번호");
		stu[1].setText( "과목 이름");
		stu[2].setText( "과목 유형");
		stu[3].setText( "과목 개요");
		stu[4].setText( "배정 학점");
		stu[5].setText( "담당 교수");
	
			/*
		
						
		*/
		
		
	
			JPanel buttonPane = new JPanel();
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
			{
				JButton okButton = new JButton("추가");
				okButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
					v.setSub_no( get[0].getText() );
					v.setSub_name( get[1].getText() );
					v.setSub_type_no( get[2].getText() );
					v.setSub_info( get[3].getText() );
					v.setSub_point( get[4].getText() );
					v.setProf_no( get[5].getText() );
										
					as.insertSubVO( v );	
					setVisible( false );
					dispose();
						
					}
				});
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				
				
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.setActionCommand("Cancel");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
				
					setVisible( false );
					dispose();
					}
				});	
				
				buttonPane.add(cancelButton);
			}
			
			setVisible(true);
		}
		
			
	}// 생성자
